package com.huiyujinrong.qiangdanbao.activity.my;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
import com.facebook.drawee.generic.RoundingParams;
import com.facebook.drawee.view.SimpleDraweeView;
import com.huiyujinrong.qiangdanbao.R;
import com.huiyujinrong.qiangdanbao.utils.JuCircle;
import com.squareup.picasso.Picasso;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 身份证明
 * 2017/4/12
 * yd
 */
public class SelectWork extends AppCompatActivity {


    @BindView(R.id.toolbar_Title)
    TextView title;
    @BindView(R.id.toolbar_Back)
    RelativeLayout back;

    @BindView(R.id.slc_gongpai)
    ImageView slc_gongpai;
    @BindView(R.id.slc_mingpian)
    ImageView slc_mingpian;


    //获取图片
    private String outputPath;
    private int inFor;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.select_work);
        ButterKnife.bind(this);
        setToolbar();

        Intent intent = getIntent();
        String gongpai = intent.getStringExtra("work_gongpai");
        String mingpian = intent.getStringExtra("work_mingpian");

        if (TextUtils.isEmpty(gongpai)) {
            slc_gongpai.setBackgroundResource(R.drawable.img_workid);
        } else {
            Picasso.with(this)
                    .load(gongpai)
                    .fit()
                    .transform(new JuCircle())
                    .into(slc_gongpai);
        }

        if (TextUtils.isEmpty(mingpian)) {
            slc_mingpian.setBackgroundResource(R.drawable.img_mingpian);
        } else {
            Picasso.with(this)
                    .load(mingpian)
                    .fit()
                    .transform(new JuCircle())
                    .into(slc_mingpian);
        }


    }

    //设置 toolbar
    private void setToolbar() {
        back.setVisibility(View.VISIBLE);
        title.setText(R.string.works);
    }


    @OnClick(R.id.toolbar_Back)
    void onClicks(View view) {
        finish();
    }

    /**
     * 设置圆角
     *
     * @param view
     */
    private void setFillet(SimpleDraweeView view) {
        RoundingParams roundingParams = RoundingParams.fromCornersRadius(20f);
        roundingParams.setOverlayColor(getResources().getColor(R.color.baise));
        GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
                .setRoundingParams(roundingParams)
                .build();
        view.setHierarchy(hierarchy);
    }

}
